home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / soundu / tnypl210.zip / MODPLAY.H < prev    next >
Text File  |  1994-05-22  |  9KB  |  271 lines

  1. /*  modplay.h - Tiny MOD Player V2.10 for Watcom C/C++ and DOS/4GW
  2.  
  3.     Module player for Sound Blaster and compatibles header file.
  4.  
  5.     Copyright 1993,94 Carlos Hasan
  6. */
  7.  
  8. /******************************************************************************\
  9.  QUICK REFERENCE GUIDE:
  10.  
  11.  MODDetectCard
  12.  ──────────────────────────────────────────────────────────────────────────────
  13.  Function:      Detect Sound Blaster card.
  14.  
  15.  Prototype:     int MODDetectCard(&Port,&IRQ,&DRQ)
  16.  
  17.  Parameters:    Port    - I/O Port address
  18.                 IRQ     - IRQ level
  19.                 DRQ     - DMA channel
  20.  
  21.  Returns:       On success, return a zero value.
  22.                 On error, return a non zero value.
  23.  
  24.  Remarks:       This function will detect the Sound Blaster card and
  25.                 will return the configuration parameters. You cannot
  26.                 call this routine while playing a module.
  27.                 Actually the routine only detect the I/O Port address
  28.                 and the IRQ level. The DMA channel 1 is always returned
  29.                 by this routine.
  30.  
  31.  
  32.  MODPlayModule
  33.  ──────────────────────────────────────────────────────────────────────────────
  34.  Function:      Start playing a Modulefile.
  35.  
  36.  Prototype:     int MODPlayModule(Song,Chans,Rate,Port,IRQ,DRQ)
  37.  
  38.  Parameters:    Song    - Address of the Module
  39.                 Chans   - Number of channels (1-8)
  40.                 Rate    - Mixing speed in Hertz (4kHz-22kHz)
  41.                 Port    - I/O Port address (220h..280h)
  42.                 IRQ     - IRQ level (2,3,5,7)
  43.                 DRQ     - DMA channel (0,1,3)
  44.  
  45.  Returns:       On success, return a zero value.
  46.                 On error, return a non zero value.
  47.  
  48.  Remarks:       This function will initialize the Sound Blaster card and
  49.                 will start playing the module file immediately. The module
  50.                 file must be a 4,6 or 8 channels Protracker or FastTracker
  51.                 music module file.
  52.                 The player supports two kinds of channels, music and sample
  53.                 audio channels. The music channels are used by the player
  54.                 to play the module, and the sample channels are used for
  55.                 sound effects and the like.
  56.                 The channels voices 0 to N-1 are used for music channels,
  57.                 where N is the number of channels of the module file.
  58.  
  59.  
  60.  MODStopModule
  61.  ──────────────────────────────────────────────────────────────────────────────
  62.  Function:      Stop playing the current Modulefile.
  63.  
  64.  Prototype:     void MODStopModule()
  65.  
  66.  Parameters:    None.
  67.  
  68.  Returns:       None.
  69.  
  70.  Remarks:       This function shut down the playing system. Must be called
  71.                 before exiting the user program.
  72.  
  73.  
  74.  MODPlaySample
  75.  ──────────────────────────────────────────────────────────────────────────────
  76.  Function:      Play instrument at specified period and volume.
  77.  
  78.  Prototype:     void MODPlaySample(Voice,Instr)
  79.  
  80.  Parameters:    Voice   - Audio channel number (0-7)
  81.                 Instr   - Instrument address
  82.  
  83.  Returns:       None.
  84.  
  85.  Remarks:       This function is useful to play samples over music. The sample
  86.                 structure holds the period, volume and the address of the 8-bit
  87.                 signed samples to be played in the channel.
  88.                 The amiga period value can be translated to hertz using the
  89.                 following formula:  Hertz = 8363*428/Period
  90.  
  91.  
  92.  MODStopSample
  93.  ──────────────────────────────────────────────────────────────────────────────
  94.  Function:      Stop a sample channel.
  95.  
  96.  Prototype:     void MODStopSample(Voice)
  97.  
  98.  Parameters:    Voice   - Audio channel number (0-7)
  99.  
  100.  Remarks:       This function will stop the specified voice setting the channel
  101.                 volume to zero. The voice should be a sample channel.
  102.  
  103.  
  104.  MODSetPeriod
  105.  ──────────────────────────────────────────────────────────────────────────────
  106.  Function:      Set the sample channel period value.
  107.  
  108.  Prototype:     void MODSetPeriod(Voice,Period)
  109.  
  110.  Parameters:    Voice   - Audio channel number (0-7)
  111.                 Period  - Amiga Period (113-856)
  112.  
  113.  Returns:       None.
  114.  
  115.  Remarks:       This function will change the current frequency of the sample
  116.                 channel. The voice should be a sample channel.
  117.  
  118.  
  119.  MODSetVolume
  120.  ──────────────────────────────────────────────────────────────────────────────
  121.  Function:      Set the sample channel volume.
  122.  
  123.  Prototype:     void MODSetVolume(Voice,Volume)
  124.  
  125.  Parameters:    Voice   - Audio channel number (0-7)
  126.                 Volume  - Volume (0-64)
  127.  
  128.  Returns:       None.
  129.  
  130.  Remarks:       This function will change the channel volume. The voice should
  131.                 be a sample channel.
  132.  
  133.  
  134.  MODSetMusicVolume
  135.  ──────────────────────────────────────────────────────────────────────────────
  136.  Function:      Set the global music channels volume.
  137.  
  138.  Prototype:     void MODSetMusicVolume(Volume)
  139.  
  140.  Parameters:    Volume  - Volume (0-255)
  141.  
  142.  Returns:       None.
  143.  
  144.  Remarks:       This function will set the global volume for all the music
  145.                 channels.
  146.  
  147.  
  148.  MODSetSampleVolume
  149.  ──────────────────────────────────────────────────────────────────────────────
  150.  Function:      Set the global sample channels volume.
  151.  
  152.  Prototype:     void MODSetSampleVolume(Volume)
  153.  
  154.  Parameters:    Volume  - Volume (0-255)
  155.  
  156.  Returns:       None.
  157.  
  158.  Remarks:       This function will set the global volume for all the sample
  159.                 channels.
  160.  
  161.  
  162.  MODLoadModule
  163.  ──────────────────────────────────────────────────────────────────────────────
  164.  Function:      Load Module file from disk.
  165.  
  166.  Prototype:     Module *MODLoadModule(Path)
  167.  
  168.  Parameters:    Path    - Module file name.
  169.  
  170.  Returns:       The module structure address or NULL of error.
  171.  
  172.  Remarks:       This function load a 4,6 or 8 channels standard Protracker
  173.                 or Fastracker module music file from disk.
  174.  
  175.  
  176.  MODFreeModule
  177.  ──────────────────────────────────────────────────────────────────────────────
  178.  Function:      Free Module file from memory.
  179.  
  180.  Prototype:     void MODFreeModule(Song)
  181.  
  182.  Parameters:    Song    - Module file address.
  183.  
  184.  Returns:       None.
  185.  
  186.  Remarks:       This function frees the module music from memory. You cannot
  187.                 free a module while it is being played.
  188.  
  189.  
  190.  MODLoadSample
  191.  ──────────────────────────────────────────────────────────────────────────────
  192.  Function:      Load sample file from disk.
  193.  
  194.  Prototype:     Sample *MODLoadSample(Path)
  195.  
  196.  Parameters:    Path    - WAV file name.
  197.  
  198.  Returns:       The sample structure address or NULL of error.
  199.  
  200.  Remarks:       This function load a RIFF/WAV sample file, the player only
  201.                 supports 8-bit mono unsigned sample file formats.
  202.  
  203.  
  204.  MODFreeSample
  205.  ──────────────────────────────────────────────────────────────────────────────
  206.  Function:      Free Sample file from memory.
  207.  
  208.  Prototype:     void MODFreeSample(Instr)
  209.  
  210.  Parameters:    Instr   - Sample file address.
  211.  
  212.  Returns:       None.
  213.  
  214.  Remarks:       This function frees the sample file from memory. You cannot
  215.                 free a sample while it is being played.
  216. \******************************************************************************/
  217.  
  218. #ifndef __MODPLAY_H
  219. #define __MODPLAY_H
  220.  
  221. typedef unsigned char byte;
  222. typedef unsigned short word;
  223. typedef unsigned long dword;
  224. typedef byte *pointer;
  225.  
  226. typedef struct {
  227.     word    NumTracks;
  228.     word    OrderLength;
  229.     byte    Orders[128];
  230.     pointer Patterns[128];
  231.     pointer SampPtr[32];
  232.     pointer SampEnd[32];
  233.     pointer SampLoop[32];
  234.     byte    SampVolume[32];
  235. } Module;
  236.  
  237. typedef struct {
  238.     word    Period;
  239.     word    Volume;
  240.     dword   Length;
  241.     pointer Data;
  242. } Sample;
  243.  
  244. #pragma aux MODDetectCard "_*" parm caller [];
  245. #pragma aux MODPlayModule "_*" parm caller [];
  246. #pragma aux MODStopModule "_*" parm caller [];
  247. #pragma aux MODPlaySample "_*" parm caller [];
  248. #pragma aux MODStopSample "_*" parm caller [];
  249. #pragma aux MODSetPeriod  "_*" parm caller [];
  250. #pragma aux MODSetVolume  "_*" parm caller [];
  251. #pragma aux MODSetMusicVolume  "_*" parm caller [];
  252. #pragma aux MODSetSampleVolume "_*" parm caller [];
  253.  
  254. extern int  MODDetectCard(word *Port, byte *IRQ, byte *DRQ);
  255. extern int  MODPlayModule(Module *Modulefile,word Chans,word Rate,word Port,byte IRQ,byte DRQ);
  256. extern void MODStopModule(void);
  257. extern void MODPlaySample(byte Voice,Sample *Instr);
  258. extern void MODStopSample(byte Voice);
  259. extern void MODSetPeriod(byte Voice,word Period);
  260. extern void MODSetVolume(byte Voice,byte Volume);
  261. extern void MODSetMusicVolume(byte Volume);
  262. extern void MODSetSampleVolume(byte Volume);
  263.  
  264. extern Module *MODLoadModule(char *Path);
  265. extern void MODFreeModule(Module *Song);
  266. extern Sample *MODLoadSample(char *Path);
  267. extern void MODFreeSample(Sample *Instr);
  268.  
  269. #endif
  270.  
  271.